package com.FH.permission.sys_menu;

import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by acer on 2016/8/3.
 */
@Path("/sysmenu")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class SysmenuResource {

    @EJB
    private SysmenuDAO sysmenuDAO;


    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getOrgroleInfo(@PathParam("search") String search, @PathParam("page") String page, @PathParam("size") String size) {
        //添加分页查询
        //添加分页查询
        if (null == page || "".equals(page) || "0".equals(page)) {
            page = "1";    //默认从第0行开始查起
        }
        if (null == size || "".equals(size)) {
            size = "10";  //每页默认10条数据
        }
        return sysmenuDAO.getSysmenuInfo(search, page, size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addSysmenuInfo(SysmenuPullDTO sysmenuPullDTO) {
        return sysmenuDAO.addSysmenuInfo(sysmenuPullDTO);
    }

    ;

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteSysmenuInfo(SysmenuShowDTO sysmenuDTO) {
        return sysmenuDAO.deleteSysmenuInfo(sysmenuDTO);
    }

    @PUT
    @Path("/update")
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO updateSysmenuInfo(SysmenuPullDTO sysmenuPullDTO) {
        return sysmenuDAO.updateSysmenuInfo(sysmenuPullDTO);
    }
}
